//
//  HeadView.m
//  Item A House
//
//  Created by dlios on 15/5/23.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "HeadView.h"
#import "FangDaiViewController.h"
@implementation HeadView

- (void)dealloc
{
    [super dealloc];
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createImage];
        [self createButton];
    
        
    }
    return self;
}
//创建图片
- (void)createImage
{
    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, ([UIScreen mainScreen].bounds.size.width * 0.5))];
    [image setImage:[UIImage imageNamed:@"0.jpg"]];
    [self addSubview:image];
}
//创建button
- (void)createButton
{
    NSMutableArray *arr = [NSMutableArray array];
    [arr addObject:@"新房"];
    [arr addObject:@"二手房"];
    [arr addObject:@"租房"];
    [arr addObject:@"房贷计算器"];
    //添加图片与文字
    for (int i = 0; i < 4; i++) {
        UIImageView *view = [[UIImageView alloc]initWithFrame:CGRectMake(12 + i * [UIScreen mainScreen].bounds.size.width / 4, 12 + ([UIScreen mainScreen].bounds.size.width * 0.5), 5 + [UIScreen mainScreen].bounds.size.width / 4 - 35, 5 + [UIScreen mainScreen].bounds.size.width / 4 - 35)];
        view.userInteractionEnabled = YES;
        view.tag = i + 1;
        NSString *str = [NSString stringWithFormat:@"%d.png", i + 1];
        [view setImage:[UIImage imageNamed:str]];
        [self addSubview:view];
        [view release];
        // 63.75   4.9039
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(i * [UIScreen mainScreen].bounds.size.width / 4, 14 + ([UIScreen mainScreen].bounds.size.width / 4 - 35) + ([UIScreen mainScreen].bounds.size.width * 0.5), 5 + [UIScreen mainScreen].bounds.size.width / 4 - 10, 20)];
        CGFloat num = (5 + [UIScreen mainScreen].bounds.size.width / 4 - 30 )/ 4.9039;
        label.text = [arr objectAtIndex:i];

        label.font = [UIFont systemFontOfSize:num];
        label.textColor = [UIColor colorWithWhite:0.3 alpha:0.8];
        label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:label];
        [label release];
    }
    
}
//添加手势
//- (void)createSeg
//{
//    UIImageView *aImage = (UIImageView *)[self viewWithTag:1];
//    UITapGestureRecognizer *recogn1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(newAction:)];
//    [aImage addGestureRecognizer:recogn1];
//    [recogn1 release];
//    
//    UIImageView *bImage = (UIImageView *)[self viewWithTag:2];
//    UITapGestureRecognizer *recogn2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(oldAction:)];
//    [bImage addGestureRecognizer:recogn2];
//    [recogn2 release];
//    
//    UIImageView *cImage = (UIImageView *)[self viewWithTag:3];
//    UITapGestureRecognizer *recogn3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rentalAction:)];
//    [cImage addGestureRecognizer:recogn3];
//    [recogn3 release];
//    
//    UIImageView *dImage = (UIImageView *)[self viewWithTag:4];
//    UITapGestureRecognizer *recogn4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(calculatorAction:)];
//    [dImage addGestureRecognizer:recogn4];
//    [recogn4 release];
//}
//- (void)newAction:(UITapGestureRecognizer *)tap
//{
//    
//}
//- (void)oldAction:(UITapGestureRecognizer *)tap
//{
//    
//}
//- (void)rentalAction:(UITapGestureRecognizer *)tap
//{
//    
//}
//- (void)calculatorAction:(UITapGestureRecognizer *)tap
//{
//    [self.delegate sendImage:(UIImageView *)tap.view];
//}
@end
